/*
 * =====================================================================================
 *
 *       Filename:  gentestset.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2015/05/17 20时58分11秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Liu Yi (), swliuyi@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include <fstream>
#include <iostream>
using namespace std;

#include "hmm.h"

int main(int argc, char* argv[])
{
  Hmm hmm;
  if (argc<3) {
    cerr << "USAGE: gentestset input output" << endl;
    return 1;
  }
  ifstream istrm(argv[1]);
  string testSet = argv[2];
  testSet += ".test";
  string answer = argv[2];
  answer += ".answer";

  vector<vector<pair<unsigned long, unsigned long> > *> trainingSequences;
  hmm.preProcess(istrm, trainingSequences, 1);
  ofstream filet(testSet.c_str());
  ofstream filea(answer.c_str());
  for( unsigned i = 0; i < trainingSequences.size() ; i++ )
  {
      for( unsigned j = 0 ; j < (*trainingSequences[i]).size() ; j++ )
      {
          string word = hmm.getStr((*trainingSequences[i])[j].first);
          filet<<word<<" ";
          filea<<word<<"/";
          filea<<hmm.getStr((*trainingSequences[i])[j].second)<<" ";
      }
      filet<<endl;
      filea<<endl;
  }
}
